/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Thai Ha Cong
 */
public class DBFactory {
    private static Connection con;
    
    public static Connection createConnection(String dbSchema){
        String dbUsername = "root";
        String dbPassword = "123456";
        String dbUrl = "jdbc:mysql://localhost:3306/" + dbSchema;
        String dbClass = "com.mysql.jdbc.Driver";
        
        try {
            Class.forName(dbClass);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(DBFactory.class.getName()).log(Level.SEVERE, null, ex);
        }

        try {
            con = DriverManager.getConnection(dbUrl, dbUsername, dbPassword);
        } catch (SQLException ex) {
            Logger.getLogger(DBFactory.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        return con;
    }
}
